package com.mustang.core.client;

import com.google.gwt.dom.client.EventTarget;
import com.mustang.core.client.type.JsObject;

/**
 * A simple Wrap class of event object in JavaScript
 * 
 * @author cuij
 *
 */
public final class Event extends JsObject
{
	
	protected Event()
	{
	}

	public native boolean eventGetAltKey() /*-{
		return !!this.altKey;
	}-*/;

	public native int eventGetButton() /*-{
		return this.button || 0;
	}-*/;

	public native int eventGetClientX() /*-{
		return this.clientX || 0;
	}-*/;

	public native int eventGetClientY() /*-{
		return this.clientY || 0;
	}-*/;

	public native boolean eventGetCtrlKey() /*-{
		return !!this.ctrlKey;
	}-*/;

	public native EventTarget eventGetCurrentTarget() /*-{
		return this.currentTarget;
	}-*/;

	public final native int eventGetKeyCode() /*-{
		// 'which' gives the right key value, except when it doesn't -- in which
		// case, keyCode gives the right value on all browsers.
		// If all else fails, return an error code
		return this.which || this.keyCode || 0;
	}-*/;

	public native boolean eventGetMetaKey() /*-{
		return !!this.metaKey;
	}-*/;

	public native int eventGetScreenX() /*-{
		return this.screenX || 0;
	}-*/;

	public native int eventGetScreenY() /*-{
		return this.screenY || 0;
	}-*/;

	public native boolean eventGetShiftKey() /*-{
		return !!this.shiftKey;
	}-*/;

	public final native String eventGetType() /*-{
		return this.type;
	}-*/;

	public native void eventSetKeyCode(char key) /*-{
		this.keyCode = key;
	}-*/;

	public native void stopPropagation() /*-{
		this.stopPropagation();
	}-*/;
}
